<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>FileInstall</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>FileInstall</h1>

<p>Includes the specified file inside the <a href="../Scripts.htm#ahk2exe">compiled version</a> of the script.</p>

<pre class="Syntax">FileInstall, Source, Dest [, Flag]</pre>
<h3>Parameters</h3>
<dl>

  <dt>Source</dt>
  <dd><p>The name of the file to be added to the compiled EXE. The file is assumed to be in (or relative to) the script's own directory if an absolute path isn't specified.</p>
    <p>The file name <strong>must not</strong> contain double quotes, variable references (e.g. %A_ProgramFiles%), or wildcards. In addition, any special characters such as literal percent signs and commas must be <a href="_EscapeChar.htm">escaped</a> (just like in the parameters of all other commands). Finally, this parameter must be listed to the right of the FileInstall command (that is, not on a <a href="../Scripts.htm#continuation">continuation line</a> beneath it).</p></dd>

  <dt>Dest</dt>
  <dd><p>When <em>Source</em> is extracted from the EXE, this is the name of the file to be created. It is assumed to be in <a href="../Variables.htm#WorkingDir">%A_WorkingDir%</a> if an absolute path isn't specified. The destination directory must already exist. Unlike <em>Source</em>, variable references may be used.</p></dd>

  <dt>Flag</dt>
  <dd><p>(optional) this flag determines whether to overwrite files if they already exist:</p>
        <p>0 = (default) do not overwrite existing files<br>
        1 = overwrite existing files</p>
        <p>This parameter can be an <a href="../Variables.htm#Expressions">expression</a>, even one that evalutes to true or false (since true and false are stored internally as 1 and 0).</p></dd>

</dl>
<h3>ErrorLevel</h3>
<p><span class="ver">[v1.1.04+]</span> This command is able to throw an exception on failure. For more information, see <a href="Catch.htm#RuntimeErrors">Runtime Errors</a>.</p>
<p><a href="../misc/ErrorLevel.htm">ErrorLevel</a> is set to 1 if there was a problem or 0 otherwise.</p>
<h3>Remarks</h3>
<p>This command is a directive for the <a href="../Scripts.htm#ahk2exe">Ahk2Exe compiler</a> that allows you to add extra files to the resulting compiled script. Later, when the compiled script is run, the files are extracted back out onto the disk.</p>
<p>The file is added <strong>during script compilation</strong>. When the compiled script is executed and the same &quot;FileInstall&quot; command is reached, the file is then extracted to <em>Dest</em>.</p>
<p>Files added to a script are compressed and also encrypted.</p>
<p>If this command is used in an normal (uncompiled) script, a simple file copy will be performed instead -- this helps the testing of scripts that will eventually be compiled.</p>
<h3>Related</h3>
<p><a href="FileCopy.htm">FileCopy</a>, <a href="_Include.htm">#Include</a></p>
<h3>Example</h3>
<pre class="NoIndent">FileInstall, C:\My Documents\My File.txt, %A_ProgramFiles%\My Application\Readme.txt, 1</pre>

</body>
</html>
